﻿#ifndef TSERVICE_H
#define TSERVICE_H

#include "../../include/itservice.h"

class ITLogger;
class ITPublicMgr;
class ITUiMgr;
/***************************Salesman**********************************/
class TmSalesman : public ITService
{
    Q_OBJECT
public:
    static TmSalesman* GetInstance() {static TmSalesman __instance; return &__instance; }
public:
    TmSalesman();
    virtual ~TmSalesman();
    virtual TRESULT Init();
    virtual TRESULT UnInit(int nTime);
    virtual TRESULT CreateTask(TArgs** ppTask,long lInArgsSize,long lOutArgsSize);
    virtual TRESULT AddTask(TArgs* pTask,int nTask);
    virtual TRESULT PostThreadMsg(unsigned long ulMsg,void* wParam,void* lParam);
    virtual TRESULT SetFramework(ITFramework* pFrm);

private:
    QThread     m_thread;
    QMutex      *m_mutex;
//    TTmMsgList  m_listTrdMsg;
    QString     m_szLog;

    ITFramework *m_pFramework;
    ITLogger    *m_pLogger;
    ITPublicMgr *m_pPublicMgr;
    ITUiMgr     *m_pUiMgr;
signals:
    void sigPostTrdMsg(unsigned long ulMsg, void *wParam, void *lParam);
private slots:
    void slotGetTrdMsg(unsigned long ulMsg, void *wParam, void *lParam);
};

/***************************TmSaleswoman*********************************/
class TmSaleswoman : public ITService
{
    Q_OBJECT
public:
    static TmSaleswoman* GetInstance() {static TmSaleswoman __instance; return &__instance; }
public:
    TmSaleswoman();
    virtual ~TmSaleswoman();
    virtual TRESULT Init();
    virtual TRESULT UnInit(int nTime);
    virtual TRESULT CreateTask(TArgs** ppTask,long lInArgsSize,long lOutArgsSize);
    virtual TRESULT AddTask(TArgs* pTask,int nTask);
    virtual TRESULT PostThreadMsg(unsigned long ulMsg,void* wParam,void* lParam);
    virtual TRESULT SetFramework(ITFramework* pFrm);

private:
    QThread     m_thread;
    QMutex      *m_mutex;
    QString     m_szLog;

    ITFramework *m_pFramework;
    ITLogger    *m_pLogger;
    ITPublicMgr *m_pPublicMgr;
    ITUiMgr     *m_pUiMgr;
signals:
    void sigPostTrdMsg(unsigned long ulMsg, void *wParam, void *lParam);
private slots:
    void slotGetTrdMsg(unsigned long ulMsg, void *wParam, void *lParam);
};

/*************************TmUiService**************************************/
class TmUiService : public ITService
{
    Q_OBJECT
public:
    static TmUiService* GetInstance() {static TmUiService __instance; return &__instance; }
public:
    TmUiService();
    virtual ~TmUiService();
    virtual TRESULT Init();
    virtual TRESULT UnInit(int nTime);
    virtual TRESULT CreateTask(TArgs** ppTask,long lInArgsSize,long lOutArgsSize);
    virtual TRESULT AddTask(TArgs* pTask,int nTask);
    virtual TRESULT PostThreadMsg(unsigned long ulMsg,void* wParam,void* lParam);
    virtual TRESULT SetFramework(ITFramework* pFrm);

private:
    QThread     m_thread;
    QMutex      *m_mutex;
    QString     m_szLog;

    ITFramework *m_pFramework;
    ITLogger    *m_pLogger;
    ITPublicMgr *m_pPublicMgr;
    ITUiMgr     *m_pUiMgr;
signals:
    void sigPostTrdMsg(unsigned long ulMsg, void *wParam, void *lParam);
private slots:
    void slotGetTrdMsg(unsigned long ulMsg, void *wParam, void *lParam);
};

#endif // TSERVICE_H
